﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Jayden.Dll.Web.HtmlControls;

namespace Jayden.Site.PopjesInDeZak.Dll
{
	public class PopjesDetailsDiv : PopjesPagedDiv
	{
		private A m_Buy;
		private A m_Add;
		private Img m_BuyImage;
		private Img m_AddImage;

		public override void Load(System.Xml.XmlNode node, Jayden.Dll.Web.HtmlControlLoader loader)
		{
			base.Load(node, loader);

			m_Buy = GetElementByServerId<A>("buy", true);
			m_BuyImage = GetElementByServerId<Img>("buyImage", true);
			m_Add = GetElementByServerId<A>("add", true);
			m_AddImage = GetElementByServerId<Img>("addImage", true);
		}

		public override void ProcessJsRequest(Jayden.Dll.Web.HttpHandlerContext context)
		{
			base.ProcessJsRequest(context);

			context.Js["PopjesDetailsDiv"].AppendOnInit(@"
	var $buy = $('#" + m_Buy.Id + @"');
	var $add = $('#" + m_Add.Id + @"');
	var $addImg = $('#" + m_AddImage.Id + @"');
	var $buyImg = $('#" + m_BuyImage.Id + @"');

	$buyImg.mouseenter(function(){ $buyImg.data('old-src', $buyImg.attr('src')); $buyImg.attr('src', '/Images/button.invoice.on.png'); });
	$buyImg.mouseleave(function(){ $buyImg.attr('src', $buyImg.data('old-src')); });

	$addImg.mouseenter(function(){ $addImg.data('old-src', $addImg.attr('src')); $addImg.attr('src', '/Images/button.add.on.png'); });
	$addImg.mouseleave(function(){ $addImg.attr('src', $addImg.data('old-src')); });
");
		}

	}
}